﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SilverBox.Extensions;
using SilverBox.Logging.Listeners;

namespace SilverBox.Demo.Log
{
    public class MyEntryListener : ILoggerListener
    {

        public MyEntryListener()
        {
            Format = "{0} :: {1}";
        }


        public string Format { get; set; }

        #region ILoggerListener Members

        public ConditionDelegate Condition
        {
            get { return obj => obj.GetType().IsOrIsBasedOn(typeof(MyEntry)); }
        }

        public string GetString(object entry)
        {
            if (Condition(entry))
            { 
                var myEntry = entry as MyEntry;
                return string.Format(Format, myEntry.Title, myEntry.Content);
            }
            throw new InvalidOperationException(string.Format("Type {0} isn't expected", entry.GetType()));
        }

        #endregion
    }
}
